@import '../custom.less';
@import './vars.less';
@import '../motion/index.less';

@drawer-prefix-cls: ~'@{css-prefix}drawer';

.@{drawer-prefix-cls} {
  .inject-Drawer-vars();

  .@{drawer-prefix-cls}__mask {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;

    &.show-bg-color {
      background-color: var(--tv-Drawer-mask-bg-color);
    }
  }

  .@{drawer-prefix-cls}__main {
    position: fixed;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--tv-Drawer-bg-color);
    box-shadow: var(--tv-Drawer-shadow);
    overflow: hidden;

    &.drag-effects {
      transition-timing-function: linear;
      transition-duration: 200ms;
      transition-property: all;
    }

    &.is-left,
    &.is-right {
      height: 100%;
    }

    &.is-top,
    &.is-bottom {
      max-height: 100%;
    }

    &.is-right {
      top: 0;
      right: 0;
      border-left-width: 0.5px;
      border-radius: 0;
    }

    &.is-left {
      top: 0;
      left: 0;
      border-right-width: 0.5px;
      border-radius: 0 var(--tv-Drawer-border-radius-size) var(--tv-Drawer-border-radius-size) 0;
    }

    &.is-top {
      top: 0;
      left: 0;
      border-bottom-width: 0.5px;
      border-radius: 0 0 var(--tv-Drawer-border-radius-size) var(--tv-Drawer-border-radius-size);
    }

    &.is-bottom {
      bottom: 0;
      left: 0;
      border-top-width: 0.5px;
      border-radius: var(--tv-Drawer-border-radius-size) var(--tv-Drawer-border-radius-size) 0 0;
    }

    .@{drawer-prefix-cls}__drag-bar {
      position: absolute;
      top: 0;
      width: 0.5rem;
      height: 100%;

      &.p-top-Bottom {
        width: 100%;
        height: 8px;
        left: 0;
        cursor: n-resize;
      }

      &.p-left-Right {
        height: 100%;
        top: 0;
        width: 8px;
        cursor: e-resize;
      }

      &.p-left {
        right: -4px;
      }

      &.p-right {
        left: -4px;
      }

      &.p-top {
        bottom: -4px;
      }

      &.p-bottom {
        top: -4px;
      }
    }

    .@{drawer-prefix-cls}__box {
      flex: auto;
      flex-direction: column;
      max-height: 100%;
      overflow: hidden;
      display: flex;

      .@{drawer-prefix-cls}__header,
      .@{drawer-prefix-cls}__footer {
        margin-left: var(--tv-Drawer-padding);
        margin-right: var(--tv-Drawer-padding);
      }

      .@{drawer-prefix-cls}__header-wrapper {
        flex: none;

        .@{drawer-prefix-cls}__headerbtn {
          border: none;
          outline: none;
          background: none;
          padding: 0;
          line-height: 1;
          position: absolute;
          top: 20px;
          right: 20px;
          cursor: pointer;
          height: 24px;
          width: 24px;

          & + .@{drawer-prefix-cls}__headerbtn {
            margin-left: 8px;
          }

          .@{drawer-prefix-cls}__close {
            font-size: 24px;
            fill: var(--tv-Drawer-close-icon-color);

            &:hover {
              fill: var(--tv-Drawer-close-icon-color-hover);
            }
          }
        }

        .@{drawer-prefix-cls}__header {
          padding: var(--tv-Drawer-padding) 0 24px;
          background: var(--tv-Drawer-bg-color);
          display: flex;
          justify-content: space-between;
          align-items: center;

          .@{drawer-prefix-cls}__title {
            text-align: left;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: var(--tv-Drawer-head-title-font-size);
            color: var(--tv-Drawer-head-title-text-color);
            font-weight: var(--tv-Drawer-head-title-font-weight);
          }

          .@{drawer-prefix-cls}__header-left {
            max-width: 80%;
            display: flex;
            align-items: center;
            padding-right: 16px;

            .@{drawer-prefix-cls}__help-icon {
              width: var(--tv-Drawer-help-icon-width-height);
              height: var(--tv-Drawer-help-icon-width-height);
              margin-left: 8px;
              fill: var(--tv-Drawer-help-icon-color);
            }
          }

          .@{drawer-prefix-cls}__header-right {
            justify-content: flex-end;
            align-items: center;
            flex: 1;
            display: flex;
          }
        }
      }

      .@{drawer-prefix-cls}__body {
        flex: auto;
        overflow: auto;
        padding: 0 var(--tv-Drawer-padding);
        border-bottom: 1px solid var(--tv-Drawer-divider-body-border-color);
      }

      .@{drawer-prefix-cls}__footer {
        flex: none;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        padding: 24px 0 var(--tv-Drawer-padding);
      }
    }
  }
}

.drawer-slide-right-enter-active {
  animation: slide-right-in var(--tv-motion-slide-speed) linear;
}

.drawer-slide-right-leave-active {
  animation: slide-right-out var(--tv-motion-slide-speed) linear;
}

.drawer-slide-left-enter-active {
  animation: slide-left-in var(--tv-motion-slide-speed) linear;
}

.drawer-slide-left-leave-active {
  animation: slide-left-out var(--tv-motion-slide-speed) linear;
}

.drawer-slide-bottom-enter-active {
  animation: slide-bottom-in var(--tv-motion-slide-speed) linear;
}

.drawer-slide-bottom-leave-active {
  animation: slide-bottom-out var(--tv-motion-slide-speed) linear;
}

.drawer-slide-top-enter-active {
  animation: slide-top-in var(--tv-motion-slide-speed) linear;
}

.drawer-slide-top-leave-active {
  animation: slide-top-out var(--tv-motion-slide-speed) linear;
}

.drawer-fade-enter-active {
  animation: fade-in var(--tv-motion-fade-speed) linear;
}

.drawer-fade-leave-active {
  animation: fade-out var(--tv-motion-fade-speed) linear;
}